package com.example.android_mvp_one.mvp.model;

import com.example.android_mvp_one.mvp.control.LreControl;
import com.example.android_mvp_one.mvp.model.api.Api;
import com.example.android_mvp_one.mvp.model.entity.BaseEntitiy;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import javax.inject.Inject;

import io.reactivex.Observable;
import io.reactivex.functions.Function;
import io.reactivex.internal.functions.Functions;

@ActivityScope
public class LreModel extends BaseModel implements LreControl.LruControlModel {

    @Inject
    public LreModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public Observable<BaseEntitiy> postNewWork() {
        Observable<BaseEntitiy> observable = null;

        Observable<BaseEntitiy> netWork = mRepositoryManager.obtainRetrofitService(Api.class).postNetWork("1", "20", "1");
        observable = Observable.fromArray( netWork ).flatMap( (Function) Functions.identity(), false, 1);

        return observable;
    }

}
